<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>公告内容</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
</head>
<style>
    .icon {
       width: 2.5em; height: 2.5em;
       vertical-align: -0.15em;
       fill: currentColor;
       overflow: hidden;
    }

    .bottom{ margin-bottom: 10px; }
</style>
<body>
    <div class="aui-content aui-margin-b-15">
        <ul class="aui-list aui-media-list" id="announcementDetails">
            <!-- <li class="aui-list-item">
                <div class="aui-media-list-item-inner">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-text bottom">
                            <div class="aui-list-item-title">公告</div>
                        </div>
                        <div class="aui-info aui-margin-t-5 bottom" style="padding:0">
                            <div class="aui-info-item">
                                <img src="../image/liulangnan.png" style="width:1rem" class="aui-img-round" />
                                <span class="aui-margin-l-5">Admin</span>
                            </div>
                            <div class="aui-info-item">2015-07-14 10:31</div>
                        </div>
                        <div class="aui-list-item-text bottom">
                            文档内容文档内容文档内容文档内容文档内容文档内容文档内容文档内容文档内容文档内容文档内容文档内容文档内容文档内容
                        </div>
                    </div>
                </div>
            </li> -->
        </ul>
    </div>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js" ></script>
<script type="text/javascript" src="../css/font/iconfont.js" ></script>
<script type="text/javascript">
    apiready = function(){
        // 加载模块
        docReader = api.require('docReader');
        // 加载数据
        if (api.pageParam.announcementId) {
            // alert(api.pageParam.announcementId)
            var url = ServeUrl + 'm=Announcement&a=getAnnouncement&id='+api.pageParam.announcementId;
        } else {
            // alert('aaa')
            var url = ServeUrl + 'm=Announcement&a=getAnnouncement';
        }
        load();
        function load () {
            // 加载内容
            api.ajax({
                url: url,
                method: 'post',
                dataType : 'json',
            }, function(ret, err) {
                if (ret) {
                    // alert(JSON.stringify(ret))
                    // 遍历公告内容
                    var str = '';
                    str += '<li class="aui-list-item">';
                    str += '<div class="aui-media-list-item-inner">';
                    str += '    <div class="aui-list-item-inner">';
                    str += '        <div class="aui-list-item-text bottom">';
                    str += '            <div class="aui-list-item-title">'+ret.title+'</div>';
                    str += '        </div>';
                    str += '        <div class="aui-info aui-margin-t-5 bottom" style="padding:0">';
                    str += '            <div class="aui-info-item">';
                    if (ret.user_img) {
                        str += '                <img src="'+ServeIp+'/include/data/headImg/'+ret.user_img+'" style="width:1rem" class="aui-img-round" />';
                    } else {
                        str += '                <img src="../image/emptyHead.jpg" style="width:1rem" class="aui-img-round" />';
                    }
                    str += '                <span class="aui-margin-l-5">'+ret.name+'</span>';
                    str += '            </div>';
                    str += '            <div class="aui-info-item">'+ret.createtime+'</div>';
                    str += '        </div>';
                    str += '        <div class="bottom">'+ret.content+'</div>';
                    str += '    </div>';
                    str += '</div>';
                    str += '</li>';
                    $('#announcementDetails').html(str);
                } else {
                    api.toast({
                        msg:'公告加载失败!'
                    });
                }
            });
        }
    
        // download();
    };
    // 回复评论
    function replyOpenWin(tag) {
        var name = tag.getAttribute('data-name');
        var cid = tag.getAttribute('data-id');
        var user = tag.getAttribute('data-user');
        // alert(user);return false
        $api.setStorage( 'backFrame' , name );  //设置需要关闭的frame
        api.openFrame({
            name: name,
            url : 'openWin.html',
            rect: {
                x: 0,
                y: 0,
                w: api.winWidth,
                h: api.winHeight
            },
            pageParam:{
                id : api.pageParam.id, // 文章id
                user : user, // 文章id
                cid : cid, // 评论id
            }
        });
    }
    // 下载文件
    function download (url, name) {
        // alert(url)
        api.download({
            url: url,
            report: false,
            cache: true,
            savePath: 'fs://download/'+name,
            allowResume: true
        }, function(ret, err) {
            if (ret.state == 1) {
                //下载成功
                // alert(ret.savePath)；
                openFile(ret.savePath)
            } else if (ret.state == 2) {} {
                // alert('下载失败');

            }
        });
    }

    function openFile (path) {
        docReader.open({
            path: path
        }, function(ret, err) {
            if (ret.status) {
                api.toast({
                    msg:'预览成功!'
                });
            } else {
                api.toast({
                    msg:'预览失败!'
                });
            }
        });
    }


    // 打开窗口
    function openWin(name) {
        api.openWin({
            name: name,
            url: name+'_win.html',
        });
    }

    // 打开frame
    function openFrame (name) {
        api.openFrame({
            name: 'date_detail',
            url: 'date_detail_frm.html',
        });
    }

    
    
</script>
</html>